<?php
/**
 * Created by PhpStorm.
 * User: yh
 * Date: 2017/12/6
 * Time: 20:35
 */
namespace app\admin\logic;

use app\admin\model\Invitation_log;

class Invitation{
    public $Invitation_log;
    /**获取模型
     * @return Depar_model|string
     */
    public function Invitation_log(){
        if (empty($this->Invitation_log)){
            $this->Invitation_log = new Invitation_log();
        }
        return $this->Invitation_log;
    }


    /**
     * 保存邀约记录
     * @param $data
     */
    public function logSaves($data){
        $res = $this->Invitation_log()->save($data);
        return $res;
    }


    /**
     * 查询邀约记录
     * @param $data
     * @return mixed
     * @author: Huang
     */
    public function logSelects($data){
        $res = $this->Invitation_log()->where($data)->order('time desc')->select();
        foreach ($res as &$v) {
            $v = $v->append(['state_text','invitation_text','tracking_text','track_text','mendian_text','nostore_text','personnel_text','budget_text','invalid_text','photo_grapher_text','payment_text'])
                ->toArray();
        };
        return $res;
    }

    /**
     *统计邀约记录数
     * @param $data
     * @return mixed
     * @author: Huang
     */
    public function logCounts($data){
        $res = $this->Invitation_log()->where($data)->count();
        return $res;
    }
}